#define _CRT_SECURE_NO_WARNINGS 
#include "qsort_bubble.h"
void Swap(char* x, char* y, size_t width)
{
	int i = 0;
	char tmp = 0;
	for (i = 0; i < width; i++)
	{
		tmp = *(x + i);
		*(x + i) = *(y + i);
		*(y + i) = tmp;
	}
}
void qsort_bubble(void* base, size_t num, size_t width, int(__cdecl* compare)(const void* elem1, const void* elem2))
{
	int i = 0, j = 0;
	for (i = 0; i < num - 1; i++)
	{
		int flag = 0;
		for (j = 0; j < num - i - 1; j++)
		{
			if (compare((char*)base + j * width, (char*)base + (j + 1) * width) > 0)
			{
				flag = 1;
				Swap((char*)base + j * width, (char*)base + (j + 1) * width, width);
			}
		}
		if (flag == 0)
			break;
	}
}